package com.region.http.client.entity;

import com.region.common.adapter.json.JSONAdapterFactory;

/**
 * @author 26225
 * @date 2023/8/26 14:16
 * @description
 */
public class ResultVO<T> {

    private String message;

    private int code;

    private T data;

    public ResultVO(String message, int code) {
        this.message = message;
        this.code = code;
    }

    public ResultVO(int code, T data) {
        this.code = code;
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> ResultVO<T> success(T data) {
        return new ResultVO<T>(0, data);
    }

    public static ResultVO error(String message) {
        return new ResultVO(1, message);
    }

    @Override
    public String toString() {
        return JSONAdapterFactory.getAdapter().toJSONString(this);
    }
}


